<?php
    include_once('Configs/database.php');
    include_once('Models/LopHocPhan.php');
    class HocKiNamHoc extends database{
        private $hocki;
        private $namhoc;
        private $ngaybd;
        private $ngaykt;
        public function setHocKi($hocki){
            $this->hocki = $hocki;
        }
        public function setNamHoc($namhoc){
            $this->namhoc = $namhoc;
        }
        public function setNgayBD($ngaybd){
            $this->ngaybd = $ngaybd;
        }
        public function setNgayKT($ngaykt){
            $this->ngaykt = $ngaykt;
        }
        public function getHocKi(){
            return $this->hocki;
        }
        public function getNamHoc(){
            return $this->namhoc;
        }
        public function getNgayBD(){
            return $this->ngaybd;
        }
        public function getNgayKT(){
            return $this->ngaykt;
        }
        public function themHocKiNamHoc(){
            $this->setQuery("insert HocKiNamHoc(hocki,namhoc,ngaybd,ngaykt) values (".$this->getHocKi().",'".$this->getNamHoc()."',str_to_date('".$this->getNgayBD()."','%d-%m-%Y'), str_to_date('".$this->getNgayKT()."','%d-%m-%Y'))");
            return $this->executeQuery();
        }
        public function suaHocKiNamHoc(){
            $this->setQuery("update HocKiNamHoc set ngaybd=str_to_date('".$this->getNgayBD()."', '%d-%m-%Y'),ngaykt=str_to_date('".$this->getNgayKT()."','%d-%m-%Y') where hocki = ".$this->getHocKi()." and namhoc='".$this->getNamHoc()."'");
            return $this->executeQuery();
        }
        public function xoaHocKiNamHoc(){
            $this->setQuery("delete from HocKiNamHoc where hocki=".$this->getHocKi()." and namhoc= '".$this->getNamHoc()."'");
            return $this->executeQuery();
        }
		public function dsNamHoc(){
			$this->setQuery("select distinct namhoc from HocKiNamHoc order by namhoc desc");
            return $this->fetchAll();
		}
        public function dsHocKiNamHoc(){
            $this->setQuery("select hocki, namhoc, date_format(ngaybd,'%d-%m-%Y') as ngaybd, date_format(ngaykt,'%d-%m-%Y') as ngaykt from HocKiNamHoc order by namhoc asc");
            return $this->fetchAll();
        }
		public function dsHocKiCuaNamHoc(){
            $this->setQuery("select hocki, namhoc, date_format(ngaybd,'%d-%m-%Y') as ngaybd, date_format(ngaykt,'%d-%m-%Y') as ngaykt from HocKiNamHoc where namhoc='".$this->getNamHoc()."'");
            return $this->fetchAll();
        }
		/* public function thongTinHocKiNamHoc(){
            $this->setQuery("select date_format(ngaybd,'%d-%m-%Y') as ngaybd, date_format(ngaykt,'%d-%m-%Y') as ngaykt from HocKiNamHoc where hocki=".$this->getHocKi()." and namhoc= '".$this->getNamHoc()."'");
            return $this->fetchAll();
        }*/
        /*public function dsLopHocPhan(){
            $lophp = new LopHocPhan();
            $lophp->setHocKi($this->hocki);
            $lophp->setNamHoc($this->namhoc);
            return $lophp->dsLopHPMoTrongHKNH();
        }*/
        
    }
?>